Lazy load for components, filters and directives (fix #8106) #8807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information:
The convincing reason was explained at length over at #8106. I know this will not be merged, in fact I'm gonna close it myself. But I'm publishing this PR for reference for anyone else interested.
The initial need was for components, but when reviewing the code I thought the most elegant way to do this was by changing the
resolveAsset()
function to call a user function defined on the$options
object:The
identifierSpellings
object has normalized spellings in case the user needs it:The nice thing about this is that it gives all the power to the user, and enables him to do many things which aren't possible with the current api, and the biggest use case is to lazily load async components only when they are needed.
I know that to submit a decent PR, I'd still need to write tests and documentation... that is the next step.
A running example can be seen here:
https://unpkg.com/@arijs/vue-generator@0.1.4/outra/pagina/
My version is released at:
https://unpkg.com/@arijs/vue@2.5.17-beta1.0/
https://www.npmjs.com/package/@arijs/vue